package com.liveinstars.api.post.facade;

import com.liveinstars.api.post.dto.BaseCommentDTO;
import com.liveinstars.api.post.dto.BaseCommentVO;
import com.liveinstars.api.post.dto.PostCommentParam;
import com.liveinstars.api.post.dto.PostDetailDto;
import com.onepiece.shipelves.common.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

import static org.springframework.data.domain.Sort.Direction.DESC;

@FeignClient("post")
public interface IPostsApi {


    @GetMapping("/post/open/{postId}/detail")
    @ApiOperation("Gets a post")
    PostDetailDto getBy(@PathVariable("postId") Integer postId);

    @GetMapping("/post/open/interestHotPost")
    @ApiOperation("interestHotPost")
    Map<Integer, List<PostDetailDto>> listByInterestHotPost(@RequestParam(value = "interestId") List<Integer> interestIds);

    @PostMapping("/post/open/{postId}/isLike")
    @ApiOperation("isLikes a post")
    Boolean isLike(@PathVariable("postId") Integer postId, @RequestHeader("uid") Integer userId);

    @PostMapping("/post/open/{postId}/likes")
    @ApiOperation("Likes a post")
    Boolean like(@PathVariable("postId") Integer postId, @RequestHeader("uid") Integer userId);

    @PostMapping("/post/open/{postId}/unLikes")
    @ApiOperation("Likes a post")
    Boolean unLike(@PathVariable("postId") Integer postId, @RequestHeader("uid") Integer userId);


    @PostMapping("/post/open/{postId}/collect")
    @ApiOperation("collect a post")
    Boolean collect(@PathVariable("postId") Integer postId, @RequestHeader("uid") Integer userId);

    @PostMapping("/post/open/{postId}/unCollect")
    @ApiOperation("uncollect a post")
    Boolean unCollect(@PathVariable("postId") Integer postId, @RequestHeader("uid") Integer userId);

    @PostMapping("/post/open/comments")
    @ApiOperation("Comments a post")
    BaseCommentDTO comment(@RequestBody PostCommentParam postCommentParam);

    @GetMapping("/post/open/{postId}/comments/tree_view")
    @ApiOperation("Lists comments with tree view")
    Page<BaseCommentVO> listCommentsTree(@SortDefault(sort = "createTime", direction = DESC) Sort sort, @PathVariable("postId") Integer postId,
                                         @RequestParam(name = "page", required = false, defaultValue = "0") int page);


//    @PostMapping("/post/open/activityComments")
//    @ApiOperation("Comments a post")
//    BaseCommentDTO activityComment(@RequestBody PostCommentParam postCommentParam);
//
//    @GetMapping("/post/open/{postId:\\d+}/activityComments/tree_view")
//    @ApiOperation("Lists comments with tree view")
//    String listActivityCommentsTree(@SortDefault(sort = "createTime", direction = DESC) Sort sort, @PathVariable("postId") Integer postId,
//                                    @RequestParam(name = "page", required = false, defaultValue = "0") int page);
}
